//
//  WDJMainAgreementView.m
//  wdj
//
//  Created by 蓝鳍互娱 on 2024/7/8.
//

#import "WDJMainAgreementView.h"
@interface WDJMainAgreementView()
@property (nonatomic,strong) UIImageView *mainAgreementImgView;
@property (nonatomic,strong) UILabel *mainAgreementLab;
@property (nonatomic,strong) UIImageView *mainAgreementGoImgView;
@property (nonatomic,strong) UIView *mainAgreementLineView;
@end
@implementation WDJMainAgreementView
-(instancetype)init{
    if (self = [super init]) {
        self.backgroundColor = UIColor.clearColor;
        [self wdjCreatView];
    }
    return self;
}
- (void)wdjCreatView{
    self.mainAgreementImgView = [[UIImageView alloc] init];
    self.mainAgreementImgView.userInteractionEnabled = true;
    [self addSubview:self.mainAgreementImgView];
    [self.mainAgreementImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([WDjWholeData wholeScreewRatio:30]));
        make.centerY.equalTo(self);
        make.height.equalTo(@([WDjWholeData wholeScreewRatio:38]));
        make.width.equalTo(@([WDjWholeData wholeScreewRatio:38]));
    }];
    self.mainAgreementLab = [[UILabel alloc] init];
    self.mainAgreementLab.font = [UIFont systemFontOfSize:[WDjWholeData wholeScreewRatio:28] weight:UIFontWeightBold];
    self.mainAgreementLab.textColor = [WDjWholeData wholeColorHexString:@"#FFFEFE"];
    [self addSubview:self.mainAgreementLab];
    [self.mainAgreementLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mainAgreementImgView);
        make.left.equalTo(self.mainAgreementImgView.mas_right).offset([WDjWholeData wholeScreewRatio:24]);
        make.height.equalTo(@([WDjWholeData wholeScreewRatio:39]));
    }];
    UIImageView * mainAgreementGoImgView = [[UIImageView alloc] init];
    mainAgreementGoImgView.image = [WDjWholeData wholeImageNamed:@"wdj_MainCenterGo"];
    mainAgreementGoImgView.userInteractionEnabled = true;
    [self addSubview:mainAgreementGoImgView];
    [mainAgreementGoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-[WDjWholeData wholeScreewRatio:32]));
        make.centerY.equalTo(self);
        make.height.equalTo(@([WDjWholeData wholeScreewRatio:18]));
        make.width.equalTo(@([WDjWholeData wholeScreewRatio:10]));
    }];
    self.mainAgreementLineView = [[UIView alloc] init];
    self.mainAgreementLineView.backgroundColor = [WDjWholeData wholeColorHexString:@"#FFFFFF" withAlph:0.2];
    [self addSubview:self.mainAgreementLineView];
    [self.mainAgreementLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@([WDjWholeData wholeScreewRatio:32]));
        make.right.equalTo(@(-[WDjWholeData wholeScreewRatio:32]));
        make.height.equalTo(@(1));
        make.bottom.equalTo(@(0));
    }];
    UIButton * mainAgreementBtn = [[UIButton alloc] init];
    [mainAgreementBtn addTarget:self action:@selector(mainAgreement) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:mainAgreementBtn];
    [mainAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@([WDjWholeData wholeScreewRatio:0]));
    }];
}
- (void)setMainAgreementType:(WDJMainAgreementType)mainAgreementType{
    _mainAgreementType = mainAgreementType;
    if(_mainAgreementType == MainAgreementTypeUser){
        self.mainAgreementImgView.image = [WDjWholeData wholeImageNamed:@"wdj_MainCenterUser"];
        self.mainAgreementLab.text = @"用户协议";
        self.mainAgreementLineView.hidden = false;
    }else if (_mainAgreementType == MainAgreementTypePrivice){
        self.mainAgreementImgView.image = [WDjWholeData wholeImageNamed:@"wdj_MainCenterPrivice"];
        self.mainAgreementLab.text = @"隐私协议";
        self.mainAgreementLineView.hidden = true;
    }
}
- (void)mainAgreement{
    if(self.MainAgreementBlock){
        self.MainAgreementBlock(_mainAgreementType);
    }
}
@end
